// g++ arena.cpp -o arena -std=c++14 -fsanitize=address -O2 -Wall -Wextra
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 0x3f3f3f3f3f3f3f3f
template<typename T> void up(T &x, T y) { x = (x > y ? x : y); }
template<typename T> void down(T &x, T y) { x = (x < y ? x : y); }
#define rep(i, a, b) for(int i = (a), i##END = (b); i <= (b); i++)
#define Rep(i, a, b) for(int i = (a), i##END = (b); i >= (b); i--)
#define N ((int)(1e5 + 15))

mt19937 rd(time(0));
int a[N], b[N], c[N];
void solve()
{
    cout << rd() << '\n';
    // bu hui zuo 555 QAQ
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("check.in", "r", stdin);
    // freopen("check.out", "w", stdout);

    freopen("arena.in", "r", stdin);
    freopen("arena.out", "w", stdout);
    
    int n, m; cin >> n >> m;
    rep(i, 1, n) cin >> a[i];
    rep(i, 1, m) cin >> b[i];
    int mx = 1; while(mx < n) mx <<= 1;
    rep(i, 1, mx - n) cin >> c[i];
    int qwq; cin >> qwq; while(qwq--) solve();
    return 0;
}